package ch19 {
	/**
	 * 二维的偏向分布
	 * @author jianping.shenjp
	 */
	import flash.display.Sprite;
    import utils.Ball;

	public class Random7 extends Sprite {
		private var numDots:uint = 300;
		private var maxRadius:Number = 50;
		private var iterations:uint = 6;

		public function Random7(){
			init();
		}

		private function init():void {
			for (var i:uint = 0; i < numDots; i++){
				var dot:Ball = new Ball(1, 0);
				var xpos:Number = 0;
				for (var j:uint = 0; j < iterations; j++){
					xpos += Math.random() * stage.stageWidth;
				}
				dot.x = xpos / iterations;
				var ypos:Number = 0;
				for (j = 0; j < iterations; j++){
					ypos += Math.random() * stage.stageHeight;
				}
				dot.y = ypos / iterations;
				addChild(dot);
			}
		}
	}

}